import { createApp } from 'vue'
import 'lib-flexible/flexible'
import './style.css'
import App from './App.vue'
import router from './router'
import { loadWechatIds } from './store.js'
import api from './api/index.js'

// 在应用启动时加载微信识别ID
loadWechatIds();

const app = createApp(App)

// 将store方法挂载到app实例上，方便全局访问
app.config.globalProperties.$store = {
  getWechatOpenId: () => {
    const { getWechatOpenId } = require('./store.js');
    return getWechatOpenId();
  },
  getWechatUnionId: () => {
    const { getWechatUnionId } = require('./store.js');
    return getWechatUnionId();
  },
  getWechatAccessToken: () => {
    const { getWechatAccessToken } = require('./store.js');
    return getWechatAccessToken();
  }
};

// 将API挂载到全局
app.config.globalProperties.$api = api;

app.use(router).mount('#app')